2740d00a7bd3f89737c6365966e4e00a935aae0b,fabric/fabric-core/src/main/scala/org/fusesource/fabric/service/KarafContainerRegistration.java,KarafContainerRegistration,configurationEvent,#ConfigurationEvent#,453

Before Change


                    int httpPort = Integer.parseInt((String) config.getProperties().get(HTTP_KEY));
                    String httpUrl = getSshUrl(name, httpPort);
                    ZooKeeperUtils.set(zooKeeper, CONTAINER_HTTP.getPath(name), httpUrl);
                    fabricService.getPortService().unRegisterPort(current, HTTP_PID);
                    fabricService.getPortService().registerPort(current, HTTP_PID, HTTP_KEY, httpPort);

                }
                if (event.getPid().equals(MANAGEMENT_PID) && event.getType() == ConfigurationEvent.CM_UPDATED) {
                    Configuration config = configurationAdmin.getConfiguration(MANAGEMENT_PID);
                    int rmiServerPort = Integer.parseInt((String) config.getProperties().get(RMI_SERVER_KEY));
                    int rmiRegistryPort = Integer.parseInt((String) config.getProperties().get(RMI_REGISTRY_KEY));
                    String sshUrl = getJmxUrl(name, rmiRegistryPort, rmiServerPort);
                    ZooKeeperUtils.set(zooKeeper, CONTAINER_JMX.getPath(name), sshUrl);
                    fabricService.getPortService().unRegisterPort(current, MANAGEMENT_PID);
                    fabricService.getPortService().registerPort(current, MANAGEMENT_PID, RMI_SERVER_KEY, rmiServerPort);
                    fabricService.getPortService().registerPort(current, MANAGEMENT_PID, RMI_REGISTRY_KEY, rmiRegistryPort);

                }
            }

After Change


                    int httpPort = Integer.parseInt((String) config.getProperties().get(HTTP_KEY));
                    String httpUrl = getSshUrl(name, httpPort);
                    ZooKeeperUtils.set(zooKeeper, CONTAINER_HTTP.getPath(name), httpUrl);
                    if (fabricService.getPortService().lookupPort(current, HTTP_PID, HTTP_KEY) != httpPort) {
                        fabricService.getPortService().unRegisterPort(current, HTTP_PID);
                        fabricService.getPortService().registerPort(current, HTTP_PID, HTTP_KEY, httpPort);
                    }
                }
                if (event.getPid().equals(MANAGEMENT_PID) && event.getType() == ConfigurationEvent.CM_UPDATED) {
                    Configuration config = configurationAdmin.getConfiguration(MANAGEMENT_PID);
                    int rmiServerPort = Integer.parseInt((String) config.getProperties().get(RMI_SERVER_KEY));
                    int rmiRegistryPort = Integer.parseInt((String) config.getProperties().get(RMI_REGISTRY_KEY));
                    String jmxUrl = getJmxUrl(name, rmiRegistryPort, rmiServerPort);
                    ZooKeeperUtils.set(zooKeeper, CONTAINER_JMX.getPath(name), jmxUrl);
                    if (fabricService.getPortService().lookupPort(current, MANAGEMENT_PID, RMI_REGISTRY_KEY) != rmiRegistryPort
                            || fabricService.getPortService().lookupPort(current, MANAGEMENT_PID, RMI_SERVER_KEY) != rmiServerPort) {
                        fabricService.getPortService().unRegisterPort(current, MANAGEMENT_PID);
                        fabricService.getPortService().registerPort(current, MANAGEMENT_PID, RMI_SERVER_KEY, rmiServerPort);
                        fabricService.getPortService().registerPort(current, MANAGEMENT_PID, RMI_REGISTRY_KEY, rmiRegistryPort);
                    }

                }